package com.cn.jinl.controller;

import com.cn.jinl.api.IPhotovoltaicManageService;
import com.cn.jinl.domain.PhotovoltaicManage;
import com.cn.jinl.utils.CommonUtil;
import com.cn.jinl.utils.JsonResponse;
import com.cn.jinl.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created On : 2024/1/18.
 * <p>
 * Author : Huiyan
 * <p>
 * Description: PhotovoltaicManageController
 */
@Controller
@RequestMapping("/photovoltaic")
public class PhotovoltaicManageController {

    @Autowired
    private IPhotovoltaicManageService photovoltaicManageService;



    @RequestMapping("/getPhotovoltaicList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<PhotovoltaicManage>> getPhotovoltaicList(@RequestBody QueryForm queryForm,@PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<List<PhotovoltaicManage>> response = new JsonResponse<>();
        List<PhotovoltaicManage> photovoltaicManages = photovoltaicManageService.getPhotovoltaicList(queryForm);
        response.setResult(photovoltaicManages);
        response.setSuccess(true);
        return response;
    }

    @RequestMapping("/getPhotovoltaicStatistics/{frontToken}")
    @ResponseBody
    public JsonResponse<Map<String,Object>> getPhotovoltaicStatistics(@RequestBody QueryForm queryForm, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<Map<String,Object>> response = new JsonResponse<>();
        Map<String,Object> photovoltaicManages = photovoltaicManageService.getPhotovoltaicStatistics(queryForm);
        response.setResult(photovoltaicManages);
        response.setSuccess(true);
        return response;
    }


    @RequestMapping("/addPhotovoltaic/{frontToken}")
    @ResponseBody
    public JsonResponse<String> addPhotovoltaic(@RequestBody PhotovoltaicManage photovoltaicManage,@PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = photovoltaicManageService.addPhotovoltaic(photovoltaicManage);
        return CommonUtil.getResponseData(response,result);
    }

    @RequestMapping("/updatePhotovoltaic/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updatePhotovoltaic(@RequestBody PhotovoltaicManage photovoltaicManage,@PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = photovoltaicManageService.updatePhotovoltaic(photovoltaicManage);
        return CommonUtil.getResponseData(response,result);
    }



    //数据中心大屏右侧---光伏清洁能源
    @RequestMapping("/bigBordPhotovoltaicData")
    @ResponseBody
    public JsonResponse<Map<String,Object>> bigBordPhotovoltaicData() throws Exception{
        JsonResponse<Map<String,Object>> response = new JsonResponse<>();
        Map<String,Object> map = photovoltaicManageService.bigBordPhotovoltaicData();
        response.setResult(map);
        response.setSuccess(true);
        return response;
    }













}
